home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Misc / emu / fbzx.lha / fbzx / characters.c < prev    next >
C/C++ Source or Header  |  2003-12-21  |  9KB  |  168 lines

  1. #include "characters.h"
  2. #include <string.h>
  3.  
  4. // prints the ASCII character CHARAC in the framebuffer MEMO, at X,Y with ink color COLOR and paper color BACK, asuming that the screen width is WIDTH
  5.  
  6. void printchar(unsigned char *memo,unsigned char carac,int x, int y, unsigned char color,unsigned char back,int width) {
  7.  
  8.   int bucle1,bucle2,pos;
  9.   unsigned char bit_rot;
  10.  
  11.   pos=0;
  12.   bit_rot=0x80;
  13.  
  14.   for(bucle1=y;bucle1<y+16;bucle1++)
  15.     for(bucle2=x;bucle2<x+16;bucle2++) {
  16.       if((characters[carac-32][pos])&bit_rot)
  17.     memo[bucle1*width+bucle2]=color;
  18.       else
  19.     memo[bucle1*width+bucle2]=back;
  20.       bit_rot/=2;
  21.       if((bucle2==x+7)||(bucle2==x+15)) {
  22.     pos++;
  23.     bit_rot=0x80;
  24.       }
  25.     }
  26. }
  27.  
  28. // prints the string CADENA in X,Y (centered if X=-1), with colors COLOR and BACK
  29.  
  30. void printstring(unsigned char *memo,unsigned char *cadena,int x,int y,unsigned char color,unsigned char back,int width) {
  31.  
  32.   int length,ncarac,bucle,xx;
  33.   int xxx,yyy;
  34.  
  35.     /*while(color>15)
  36.         color-=16;
  37.  
  38.     while(back>15)
  39.         back-=16;*/
  40.     
  41.   ncarac=strlen(cadena);
  42.   length=16*ncarac;
  43.  
  44.   if(length>width) 
  45.     xx=x;
  46.   else {
  47.     if(x==-1) // we want it centered
  48.       xx=(width/2)-(length/2);
  49.     else
  50.       xx=x;
  51.   }
  52.  
  53.   xxx=xx;
  54.   yyy=y;
  55.   for(bucle=0;bucle<ncarac;bucle++) {
  56.     printchar(memo,cadena[bucle],xxx,yyy,color,back,width);
  57.     xxx+=16;
  58.     if(xxx>=width-16) {
  59.       xxx=0;
  60.       yyy+=20;
  61.     }
  62.   }
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. unsigned char characters[96][32]={
  72. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  73. {0,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,2,0,2,0,2,0,0,0,0,0,3,0,3,0,0,0},
  74. {0,0,28,224,28,224,28,224,28,224,8,64,8,64,8,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  75. {0,0,2,64,2,64,2,64,2,64,2,64,31,240,4,128,4,128,4,128,63,224,4,128,4,128,4,128,4,128,0,0},
  76. {0,0,1,0,3,208,4,48,8,16,8,0,8,0,4,0,3,192,0,32,0,16,0,16,16,16,24,32,23,192,1,0},
  77. {14,0,17,0,32,128,32,128,32,128,17,0,14,56,1,192,14,0,112,224,1,16,2,8,2,8,2,8,1,16,0,224},
  78. {0,0,0,0,7,64,9,128,8,0,8,0,4,0,12,0,18,96,34,64,33,128,32,128,32,192,17,64,14,48,0,0},
  79. {0,0,3,128,3,128,3,128,3,128,3,128,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  80. {0,0,0,64,0,128,0,128,0,128,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,128,0,128,0,128,0,64},
  81. {0,0,16,0,8,0,8,0,8,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,8,0,8,0,8,0,16,0},
  82. {0,0,1,0,1,0,1,0,25,48,15,224,3,128,6,192,12,96,24,48,0,0,0,0,0,0,0,0,0,0,0,0},
  83. {0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,63,248,1,0,1,0,1,0,1,0,1,0,0,0,0,0},
  84. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,128,3,128,7,0,6,0},
  85. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  86. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,128,3,128,3,128,0,0},
  87. {0,0,0,16,0,32,0,32,0,64,0,64,0,128,0,128,1,0,1,0,2,0,2,0,4,0,4,0,8,0,8,0},
  88. {0,0,3,128,12,96,8,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,8,32,12,96,3,128},
  89. {0,0,3,0,29,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,31,240},
  90. {0,0,7,128,24,64,32,32,32,32,0,32,0,32,0,64,0,128,1,0,2,0,4,0,8,0,16,0,32,16,63,240},
  91. {0,0,15,128,16,96,0,32,0,32,0,32,0,64,7,128,0,96,0,16,0,16,0,16,0,16,32,16,24,96,7,128},
  92. {0,0,0,192,1,64,2,64,2,64,4,64,8,64,8,64,16,64,16,64,32,64,63,240,0,64,0,64,0,64,3,240},
  93. {0,0,31,224,16,0,16,0,16,0,16,0,23,128,24,96,0,32,0,16,0,16,0,16,0,16,0,32,48,96,15,128},
  94. {0,0,1,224,6,0,12,0,8,0,16,0,19,192,20,32,24,16,16,16,16,16,16,16,16,16,8,16,12,32,3,192},
  95. {0,0,63,224,32,32,32,64,0,64,0,64,0,128,0,128,0,128,0,128,1,0,1,0,1,0,2,0,2,0,2,0},
  96. {0,0,7,128,8,64,16,32,16,32,16,32,16,32,8,64,15,192,16,32,32,16,32,16,32,16,16,32,24,96,7,128},
  97. {0,0,3,128,12,96,24,48,16,16,16,16,16,16,8,48,12,80,3,144,0,16,0,16,0,32,0,32,0,192,31,0},
  98. {0,0,0,0,0,0,0,0,3,128,3,128,3,128,0,0,0,0,0,0,0,0,0,0,3,128,3,128,3,128,0,0},
  99. {0,0,0,0,0,0,7,0,7,0,7,0,0,0,0,0,0,0,0,0,0,0,7,0,7,0,14,0,12,0,24,0},
  100. {0,0,0,0,0,0,0,48,0,192,3,0,12,0,48,0,96,0,48,0,12,0,3,0,0,192,0,48,0,0,0,0},
  101. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,248,0,0,0,0,63,248,0,0,0,0,0,0,0,0,0,0},
  102. {0,0,0,0,0,0,48,0,12,0,3,0,0,192,0,48,0,24,0,48,0,192,3,0,12,0,48,0,0,0,0,0},
  103. {0,0,31,0,32,128,32,64,0,64,0,64,0,64,0,128,3,0,4,0,4,0,0,0,0,0,6,0,6,0,0,0},
  104. {0,0,7,128,24,64,16,32,32,32,32,224,33,32,34,32,34,32,34,32,34,32,33,32,32,240,16,0,24,96,7,192},
  105. {0,0,31,128,2,128,4,64,4,64,4,64,8,32,8,32,8,32,31,240,16,16,16,16,32,8,32,8,120,60,0,0},
  106. {0,0,127,224,16,16,16,8,16,8,16,8,16,16,31,224,16,16,16,8,16,8,16,8,16,8,16,16,127,224,0,0},
  107. {0,0,3,200,12,40,24,24,16,8,32,0,32,0,32,0,32,0,32,0,32,0,16,8,24,24,12,48,3,192,0,0},
  108. {0,0,127,192,32,48,32,16,32,8,32,8,32,8,32,8,32,8,32,8,32,8,32,8,32,16,32,48,127,192,0,0},
  109. {0,0,127,240,16,16,16,16,16,16,17,0,17,0,31,0,17,0,17,0,16,8,16,8,16,8,16,8,127,248,0,0},
  110. {0,0,63,248,8,8,8,8,8,8,8,128,8,128,15,128,8,128,8,128,8,0,8,0,8,0,8,0,63,128,0,0},
  111. {0,0,7,144,24,80,48,48,32,16,64,0,64,0,64,0,64,0,65,248,64,16,32,16,48,16,24,32,7,192,0,0},
  112. {0,0,124,124,16,16,16,16,16,16,16,16,16,16,31,240,16,16,16,16,16,16,16,16,16,16,16,16,124,124,0,0},
  113. {0,0,31,240,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,31,240,0,0},
  114. {0,0,7,252,0,32,0,32,0,32,0,32,0,32,0,32,0,32,32,32,32,32,32,32,32,64,16,192,15,0,0,0},
  115. {0,0,124,120,16,32,16,64,16,128,17,0,18,0,22,0,25,0,16,128,16,64,16,32,16,32,16,16,124,60,0,0},
  116. {0,0,127,0,8,0,8,0,8,0,8,0,8,0,8,0,8,0,8,0,8,8,8,8,8,8,8,8,127,248,0,0},
  117. {0,0,112,28,48,24,48,24,40,40,40,40,36,72,36,72,34,136,35,136,32,8,32,8,32,8,32,8,120,60,0,0},
  118. {0,0,240,252,48,16,40,16,36,16,36,16,34,16,34,16,33,16,33,16,32,144,32,144,32,80,32,48,252,48,0,0},
  119. {0,0,7,192,24,48,48,24,32,8,64,4,64,4,64,4,64,4,64,4,64,4,32,8,48,24,24,48,7,192,0,0},
  120. {0,0,63,224,8,16,8,8,8,8,8,8,8,8,8,16,15,224,8,0,8,0,8,0,8,0,8,0,63,128,0,0},
  121. {0,0,7,192,24,48,48,24,32,8,64,4,64,4,64,4,64,4,64,4,64,4,32,8,48,24,24,48,7,192,3,24},
  122. {0,0,127,192,16,32,16,16,16,16,16,16,16,16,16,32,31,192,16,128,16,64,16,32,16,32,16,16,124,28,0,0},
  123. {0,0,7,144,24,80,32,48,32,16,32,0,24,0,7,128,0,96,0,16,0,16,32,16,48,16,40,32,39,192,0,0},
  124. {0,0,63,248,33,8,33,8,33,8,33,8,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,15,224,0,0},
  125. {0,0,124,248,32,16,32,16,32,16,32,16,32,16,32,16,32,16,32,16,32,16,32,16,32,16,16,32,15,192,0,0},
  126. {0,0,124,124,32,8,32,8,16,16,16,16,8,32,8,32,8,32,4,64,4,64,4,64,2,128,3,128,1,0,0,0},
  127. {0,0,124,124,32,8,32,8,33,8,33,8,34,136,34,136,18,144,20,80,20,80,20,80,24,48,24,48,24,48,0,0},
  128. {0,0,124,124,16,16,8,32,8,32,4,64,2,128,1,0,2,128,4,64,4,64,8,32,16,16,16,16,124,124,0,0},
  129. {0,0,120,60,16,16,8,32,8,32,4,64,4,64,2,128,1,0,1,0,1,0,1,0,1,0,1,0,15,224,0,0},
  130. {0,0,63,240,32,16,32,32,32,64,32,128,0,128,1,0,2,0,4,0,4,16,8,16,16,16,32,16,63,240,0,0},
  131. {0,0,1,192,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,192},
  132. {16,0,16,0,8,0,8,0,4,0,4,0,2,0,2,0,1,0,1,0,0,128,0,128,0,64,0,64,0,32,0,32},
  133. {0,0,7,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,7,0},
  134. {0,0,2,0,7,0,8,128,16,64,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  135. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,254,0,0},
  136. {0,0,12,0,6,0,3,0,1,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  137. {0,0,0,0,0,0,0,0,15,128,16,64,0,32,0,32,15,160,16,96,32,32,32,32,32,32,16,96,15,184,0,0},
  138. {0,0,112,0,16,0,16,0,19,224,20,24,24,8,16,4,16,4,16,4,16,4,16,4,24,8,20,24,115,224,0,0},
  139. {0,0,0,0,0,0,0,0,7,208,24,48,16,16,32,16,32,0,32,0,32,0,32,0,16,24,24,48,7,192,0,0},
  140. {0,0,0,112,0,16,0,16,15,144,48,80,32,48,64,16,64,16,64,16,64,16,64,16,32,48,48,80,15,156,0,0},
  141. {0,0,0,0,0,0,0,0,7,192,24,48,16,16,32,8,32,8,63,248,32,0,32,0,16,0,24,24,7,224,0,0},
  142. {0,0,1,240,3,8,2,0,2,0,31,240,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,31,240,0,0},
  143. {0,0,0,0,0,0,0,0,7,216,8,48,16,16,16,16,16,16,16,16,8,48,7,208,0,16,0,32,0,96,7,192},
  144. {0,0,112,0,16,0,16,0,16,0,19,192,20,32,24,16,16,16,16,16,16,16,16,16,16,16,16,16,124,124,0,0},
  145. {0,0,1,0,1,0,0,0,0,0,15,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,31,240,0,0},
  146. {0,0,0,64,0,64,0,0,0,0,31,224,0,32,0,32,0,32,0,32,0,32,0,32,0,32,0,64,0,192,31,0},
  147. {0,0,56,0,8,0,8,0,8,0,8,240,8,64,8,128,9,0,10,0,14,0,9,0,8,128,8,64,56,120,0,0},
  148. {0,0,31,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,63,248,0,0},
  149. {0,0,0,0,0,0,0,0,238,112,49,136,33,8,33,8,33,8,33,8,33,8,33,8,33,8,33,8,249,140,0,0},
  150. {0,0,0,0,0,0,0,0,115,192,20,32,24,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,124,124,0,0},
  151. {0,0,0,0,0,0,0,0,7,192,24,48,16,16,32,8,32,8,32,8,32,8,32,8,16,16,24,48,7,192,0,0},
  152. {0,0,0,0,0,0,0,0,55,192,24,32,16,16,16,16,16,16,16,16,24,32,23,192,16,0,16,0,16,0,126,0},
  153. {0,0,0,0,0,0,0,0,7,216,8,48,16,16,16,16,16,16,16,16,8,48,7,208,0,16,0,16,0,16,0,252},
  154. {0,0,0,0,0,0,0,0,28,112,5,136,6,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,63,224,0,0},
  155. {0,0,0,0,0,0,0,0,7,208,8,48,8,16,8,0,7,0,0,224,0,16,0,16,16,16,24,32,23,192,0,0},
  156. {0,0,8,0,8,0,8,0,63,224,8,0,8,0,8,0,8,0,8,0,8,0,8,0,8,0,4,48,3,192,0,0},
  157. {0,0,0,0,0,0,0,0,112,112,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,8,80,7,152,0,0},
  158. {0,0,0,0,0,0,0,0,124,124,16,16,16,16,8,32,8,32,8,32,4,64,4,64,2,128,3,128,1,0,0,0},
  159. {0,0,0,0,0,0,0,0,120,60,32,8,32,8,33,8,17,16,18,144,18,144,18,144,10,160,12,96,12,96,0,0},
  160. {0,0,0,0,0,0,0,0,60,120,16,16,8,32,4,64,2,128,1,0,2,128,4,64,8,32,16,16,60,120,0,0},
  161. {0,0,0,0,0,0,0,0,30,120,4,32,4,32,4,64,2,64,2,128,1,128,1,0,3,0,2,0,63,128,0,0},
  162. {0,0,0,0,0,0,0,0,31,240,16,16,16,32,0,64,0,128,1,0,2,0,4,0,8,16,16,16,31,240,0,0},
  163. {0,0,0,192,1,0,1,0,1,0,1,0,1,0,1,0,6,0,1,0,1,0,1,0,1,0,1,0,1,0,0,192},
  164. {0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
  165. {0,0,6,0,1,0,1,0,1,0,1,0,1,0,1,0,0,192,1,0,1,0,1,0,1,0,1,0,1,0,6,0},
  166. {0,0,0,0,0,0,0,0,0,0,15,12,25,152,48,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  167. {0,0,85,84,0,0,64,4,0,0,64,4,0,0,64,4,0,0,64,4,0,0,64,4,0,0,85,84,0,0,0,0}};
  168.